<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">知识库应用管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>知识库应用管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">知识库产品管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">
		<!--BEGIN CONTENT-->
		<div class="row">
			<ul id="generalTab" class="nav nav-tabs ul-edit responsive">
				<li class="active"><a href="#dp-tab" data-toggle="tab">第三方互联登录</a>
				</li>
				<li><a href="#op-tab" data-toggle="tab"
					onclick="queryrelevance()">支付方式配置</a></li>
			</ul>
			<div id="generalTabContent" class="tab-content responsive">
				<div id="dp-tab" class="tab-pane fade in active">

					<div class="row mbl">
						<div class="col-lg-6">
							<div class="input-group input-group-sm mbs">
								<span class="input-group-btn">
									<button class="btn btn-sm btn-success"
										style="margin-left: 10px;" onclick="addedie(0)">新建互联登录配置</button>
								</span>
							</div>
						</div>
					</div>

					<table
						class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
						<thead>
							<tr>
								<th>序号</th>
								<th>类型</th>
								<th>appid</th>
								<th>appsecret</th>
								<th>可操作</th>
							</tr>

						</thead>
						<thead id="findMemeber">
						</thead>
					</table>

				</div>
				<div id="op-tab" class="tab-pane fade">
					<div class="row mbl">
						<div class="col-lg-6">
							<div class="input-group input-group-sm mbs">
								<span class="input-group-btn">
									<button class="btn btn-sm btn-success"
										style="margin-left: 10px;" onclick="addpay(0)">新建支付方式配置</button>
								</span>
							</div>
						</div>
					</div>

					<table
						class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
						<thead>
							<tr>
								<th>序号</th>
								<th>类型</th>
								<th>appid</th>
								<th>appsecret</th>
								<th>可操作</th>
							</tr>
					<!-- 		<tr>
								<td style="line-height: 64px;">1</td>
								<td><img alt="" src="images/zhifubao.png" width="64">
								</td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">编辑 删除</td>
							</tr>
							<tr>
								<td style="line-height: 64px;">2</td>
								<td><img alt="" src="images/weixin.png" width="64"></td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">编辑 删除</td>
							</tr>
							<tr>
								<td style="line-height: 64px;">3</td>
								<td><img alt="" src="images/yinlian.png" width="64">
								</td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">4061994903</td>
								<td style="line-height: 64px;">编辑 删除</td>
							</tr> -->
						</thead>

						<thead id="kfindMemeber">
						</thead>
					</table>
				</div>
				<!--END TITLE & BREADCRUMB PAGE-->
				<!--BEGIN CONTENT-->


			</div>


			<!--END CONTENT-->
		</div>


		<!--END CONTENT-->
	</div>
</div>

<?} ?>
<script>
	var curr;
	var id;
	$(function() {

		demo1(1);
	});
	
	function get() {
		demo1(1);
		queryrelevance();
	}
	
	function getlay() {
		return id;
	}
	function delww(iid) {
		if (confirm("是否确认删除！！")) {
			$.ajax({
				type : "post",
				url : "./openLogindel.do",
				data : {
					"id" : iid
				},
				dataType : "json",
				success : function(data) {
					get();
					layer.msg('删除成功');
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
	}
	function addedie(lid) {
		id = lid;
		layer.open({
			type : 2,
			area : [ '500px', '310px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,

			title : '知识库应用配置',
			//maxmin : true,  
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : [ "application_setting_add.html", 'no' ],
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.Page();
			},
		});
	}
	function demo1() {
		$
				.getJSON(
						"listfindConfiguration.do",
						{
							type : 1
						},
						function(res) {
							//此处仅仅是为了演示变化的内容
							var str = "";

							$("#findMemeber").html("");

							for ( var i = 0; i < res.length; i++) {
								var typeList;
								if (res[i].type == 0) {
									typeList = "新浪微博";
								} else if (res[i].type == 1) {
									typeList = "QQ互联";
								} else {
									typeList = "微信登录";
								}
								str += "<tr><td>"
										+ (i + 1)
										+ "</td><td> <label id=>"
										+ typeList
										+ "</label></td><td><label >"
										+ res[i].appid
										+ "</label></td><td><label >"
										+ res[i].appsecret
										+ "</label></td><td>"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"addedie('"
										+ res[i].id
										+ "')\">"
										+ "编辑"
										+ "</button>&nbsp;&nbsp;&nbsp;"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\" onclick=\"delww('"
										+ res[i].id + "')\">" + "删除"
										+ "</button></td></tr>";
							}
							$("#findMemeber").append(str);

						});
	};
	function del(payid) {
		if (confirm("是否确认删除！！")) {
			$.ajax({
				type : "post",
				url : "./paymentdel.do",
				data : {
					"id" : payid
				},
				dataType : "json",
				success : function(data) {
					get();
					layer.msg('删除成功');
				},
				error : function(data) {
					alert("请求失败");
				}
			});
		}
	}
	function addpay(pid) {
		id = pid;
		layer.open({
			type : 2,
			area : [ '500px', '310px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,

			title : '知识库应用配置',
			//maxmin : true,  
			move : false,
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : [ "application_setting_payment_add.html", 'no' ],
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.Page();
			},
		});
	}
	function queryrelevance() {
	
		$.getJSON(
						"listfindPayment.do",
						{
							type : 1
						},
						function(res) {
							//此处仅仅是为了演示变化的内容
						
							var str = "";
							
							$("#kfindMemeber").html("");
							for ( var i = 0; i < res.length; i++) {
							var typeList='';
								if (res[i].type == 0) {
									typeList += '<img alt="" src="images/zhifubao.png" width="64">';
								} else if (res[i].type == 1) {
									typeList += '<img alt="" src="images/weixin.png" width="64">';
								} else {
									typeList += '<img alt="" src="images/yinlian.png" width="64">';
								}
								str += "<tr><td>"
										+ (i + 1)
										+ "</td><td><label >"
										+ typeList
										+ "</td><td><label >"
										+ res[i].appid
										+ "</label></td><td><label >"
										+ res[i].appsecret
										+ "</label></td><td>"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"addpay('"
										+ res[i].id
										+ "')\">"
										+ "编辑"
										+ "</button>&nbsp;&nbsp;&nbsp;"
										+ "<button type=\"button\" class=\"btn btn-default btn-xs\" onclick=\"del('"
										+ res[i].id + "')\">" + "删除"
										+ "</button></td></tr>";
							}
							$("#kfindMemeber").append(str);

						});
	};
</script>